<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        /* 
          函数是可以互相调用的          
        */
        // 买土豆
        function buy(shopping) {
            console.log('去超市');
            if (shopping == '土豆') {
                console.log('挑选土豆');
                shopping = '土豆';
            } else if(shopping == '西红柿'){
                console.log('挑选西红柿');
                shopping = '西红柿';
            }else{
                console.log('挑选鸡蛋');
                shopping = '鸡蛋';
            }
            return shopping;
        }
        //  土豆炖牛腩
        function beff(){
            let potato = buy('土豆');
            console.log('切'+potato);
            console.log('切牛肉');
            console.log('炒菜');
            console.log('土豆牛腩做好啦');
        }
        // 西红柿炒鸡蛋
        function tomato(){
            let potato = buy('西红柿');
            let egg = buy('鸡蛋');
            console.log('炒'+potato+egg);
            console.log('西红柿鸡蛋炒好啦');
        }
        tomato();
        beff();
    </script>
</body>

</html>